#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
GOLO_Ver='0.3'
. /opt/openresty/nginx/scripts/golo.conf
source $ROS_RTK_WS_PATH
sudo chmod 777 /dev/v4l/by-path/*
moak_version=$(rosversion merged_percept |awk -F'.' '{print $1 $2}')
RosC=$(rosnode list|grep mo_camera |wc -l)
roscd moak_cam_scan
moak_dir=$(pwd)
if [ $moak_version == 22 ];then
sudo sed -i 's#<param name="ENABLE_DRIVER_NODE_DEBUG_OUTPUT"  type="int" value="1" />#<param name="ENABLE_DRIVER_NODE_DEBUG_OUTPUT"  type="int" value="0" />#' $moak_dir/launch/mo_camera_scan.launch
else
rosnode kill /mo_calibrator
rosnode kill /mo_camera
pkill -f calib.launch
echo y |rosnode cleanup
fi
moak_failed=$( ls /tmp/moak_cam_failed*.lock|wc -l )
if [ $moak_failed -ne 0 ];then
  sudo rm -rf /tmp/moak_cam_failed*.lock
fi
sudo chmod 777 /dev/v4l/by-path/*
sudo systemctl restart goloC
RosWM=$(rosnode list|grep golo_monitor |wc -l)
if [ $RosWM == 0 ];then
   sudo systemctl start goloWM	
fi
RosCron=$(sudo service cron status |grep running |wc -l)
if [ $RosCron == 0 ];then
	   sudo service cron  start 
fi
#NGX=`rosnode list |grep mo_camera|wc -l`
#rosnode kill /mo_camera
#rosnode kill /map_to_camera
#if [ "$NGX" -ne 0 ]
#   then
# roslaunch moak_asic_dsp_uv  mo_camera.launch     
#   else
# echo -en "cam  is running！" 
#fi

